import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;

import java.io.IOException;
import java.net.InetSocketAddress;

/**
 * Created by Cheng on 2017/5/9.
 */
public class MainServer {

    private static final  int Port = 8080;

    public static void main(String[] args) {

        IoAcceptor ioAcceptor = new NioSocketAcceptor();
        System.out.println("server staring......");
        ioAcceptor.setHandler(new HelloWorldHandler());
        ioAcceptor.getSessionConfig().setReadBufferSize(2048);
        ioAcceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
        try {
            ioAcceptor.bind(new InetSocketAddress(Port));
        } catch (IOException e) {
            /* TODO Auto-generated catch block */
            e.printStackTrace();
        }
    }
}
